﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using LikeUs.WebService.Client;
using LikeUs.WebService.Client.WSInfoClient;

namespace LikeUsWebSite.Account
{
    public partial class Register : System.Web.UI.Page
    {

        protected void Page_Load(object sender, EventArgs e)
        {
           // RegisterUser.ContinueDestinationPageUrl = Request.QueryString["ReturnUrl"];
        }

        protected void RegisterUser_CreatedUser(object sender, EventArgs e)
        {
            FormsAuthentication.SetAuthCookie(RegisterUser.UserName, true /* createPersistentCookie */);
            Session.Timeout = 180;
            WSInfoProxy wsProxy = new WSInfoProxy();
            UserData user = wsProxy.GetUser(Int32.Parse(Membership.GetUser().Comment),null);
            Response.AppendCookie(new HttpCookie("userid", user.UserID.ToString()));
            user.Name1 = ((TextBox)RegisterUser.FindControl("RegisterUserWizardStep").Controls[0].FindControl("Name")).Text;
            wsProxy.UpdateUserData(user);

            string continueUrl = RegisterUser.ContinueDestinationPageUrl;
            if (String.IsNullOrEmpty(continueUrl))
            {
                continueUrl = "~/";
            }

            Session["userData"] = user;
            Response.Redirect("../Learning.aspx");
        }
    }
}
